﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace Super64.Emulation
{
    public class Memory
    {
        private byte[] ram = new byte[0x10000];
        public byte rb(ushort addr)
        {
            return ram[addr];
        }
        public void wb(ushort addr, byte data)
        {
            ram[addr] = data;
        }
        public void LoadKernal(object sender, CancelEventArgs e)
        {
            OpenFileDialog ofd = (OpenFileDialog)sender;
            Stream stream = ofd.OpenFile();
            try
            {
                for (int i = 0; i < 0x2000; i++)
                {
                    stream.Read(ram,0xE000,0x2000);
                }
            }
            catch(Exception except)
            {
                Application.Exit();
            }
        }
        public void LoadBasic(object sender, CancelEventArgs e)
        {
            OpenFileDialog ofd = (OpenFileDialog)sender;
            Stream stream = ofd.OpenFile();
            try
            {
                for (int i = 0; i < 0x2000; i++)
                {
                    stream.Read(ram, 0xA000, 0x2000);
                }
            }
            catch (Exception except)
            {
                Application.Exit();
            }
        }
    }
}
